'''
This my_if

>>>from my_if import myif
>>>a = myif(speed=True, errorinfo=None)
>>>a.update('first', 1)
>>>a.update('second', 2)
>>>a.switch(1)
'first'
>>>a.switch('3')
>>>print(a.switch('3'))
None

--------------------------------------------------------------------------------------------------


>>>from my_if import myif
>>>a = myif(return_type='function')
>>>def main(): print('this is main.')
>>>def asd(): print('this is asd.')
>>>a.update(main(), 1)
>>>a.update(asd(), 1)
>>>a.switch(1)
this is main.
>>>a.switch(3)
"Don't the value in you update"
'''
#0.1.0
class myif(object):
    def __init__(self, **kawargs):
         self.af = 0
         self.kawargs = kawargs
         try:
             if kawargs['speed']:
                 self.value = {}
         except:
             self.deff = []
             self.age=[]
             self.kawargs['speed'] = False
         if self.kawargs.get('return_type', None):
             self.kawargs['return_type']=False
    def update(self, deff, age):
        if self.kawargs['speed']:
            self.speedd(deff, age)
        else:
            self.deff.append(deff)
            self.age.append(age)
    def switch(self, age):
        if self.kawargs['speed']:
            for a in self.value:
                if a == age and self.kawargs == 'function':
                    self.value[a]
                elif a == age:
                    return self.value[a]
        else:
            for a in self.age:
                if a == age and self.kawargs == 'function':
                    self.deff[self.af]
                elif a == age:
                    return self.deff[self.af]
                else:
                    self.af += 1

        return self.kawargs.get('errorinfo', "Don't the value in you update")
    def speedd(self, deff, age):
        self.value[age]=deff
